<template>
	<view class="billdetails">
		<view class="billdetails_top">
			<view class="name">{{name}}{{address}}</view>
			<view class="moeny">{{Number(money).toFixed(2)}}</view>
			<view class="last">{{billList.order.status==1?'待缴费':'已缴费'}}</view>
		</view>
		<!-- 分割线 -->
		<view class="xian ">
			<view class="xian_left"></view>
			<view class="xian_center"></view>
			<view class="xian_right"></view>
		</view>
		<!-- 主体内容 -->
		<view class="main">
			<view class="main_jh">
				<view class="zdbh clearfix">
					<view class="bh">账单编号</view>
					<view class="num">{{billList.order.code}}</view>
				</view>
				<!-- <view class="zdbh clearfix" v-show="billList.order.status==1">
					<view class="bh">截止时间</view>
					<view class="num">{{num}}</view>
				</view> -->
			</view>
			<view class="wyf">
				<view v-for="(item,index) in billList.childList" :key='index' class="clearfix view">
					<view class="u-font-32 u-m-b-20">
						{{item.startTime}}~{{item.endTime}}
					</view>
					<view class="wyfname">物业费</view>
					<view class="wyfmoney">{{(Math.round((item.wuYeMoney+item.fuJiaMoney+item.weiYueMoney)*100)/100)}}
					</view>
				</view>
			</view>
			<!-- <view class="main_jh">
				<view class="zdbh clearfix" v-show="billList.order.status==2">
					<view class="bh">缴费时间</view>
					<view class="num">{{num}}</view>
				</view>
			</view> -->
			<!-- <view class="zdbh clearfix" v-show="billList.order.status==2">
				<view class="bh">支付方式</view>
				<view class="num">{{num}}</view>
			</view> -->
			<!-- <view class="zdbh clearfix" v-show="billList.order.status==2">
				<view class="bh">交易单号</view>
				<view class="num">{{num}}</view>
			</view> -->
			<!-- <view class="zdbh clearfix" v-show="billList.order.status==2">
				<view class="bh">支付人</view>
				<view class="num">{{num}}</view>
			</view> -->
			<view class="u-p-r-40 u-p-l-40 bill-deta-btn" v-show="billList.order.status==1">
				<u-button @click="payClick" type="warning">缴费</u-button>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				allmoney: '3600.00',
				type: '已支付',
				num: 'WY20200807',
				billList: {},
				homelist: '',
				name: '',
				address: '',
				money: '',
				chooseList: [],
			}
		},
		onShow() {
			this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
			this.name = this.homelist.proName;
			this.address = this.homelist.buildDistrictCode + '-' + this.homelist.buildTowerCode + '-' + this.homelist
							.roomUnitNumber +
					'-' + this.homelist.roomCode
			this.money = this.$Route.query.money
			this.chooseList = this.$Route.query.chooseList
			this.getBillDetail()

		},
		methods: {
			async getBillDetail() {
				let res = await this.$request.api.billDetails({
					setId: this.homelist.setId,
					id: this.$Route.query.id,
					mobile: uni.getStorageSync('phone')
				})
				console.log(res)
				this.billList = res.data.data
				console.log(this.billList)
			},
			async payClick() {
				let data = {
					id: this.$Route.query.id,
					mobile: uni.getStorageSync('phone'),
					proId: this.homelist.proId,
					money: Number(this.money).toFixed(2),
					code: this.billList.order.code,
					name: this.name,
					address: this.address,
					setId: this.homelist.setId,
					childList:this.billList.childList,
					billList: this.billList,
					source:'APP001',
					//orderObj:this.billList.order
				}
				console.log(this.billList.order,'===跳转小程序之前参数')
				let str = JSON.stringify(data)
				// 小程序跳转
				plus.share.getServices(
						res => {
							let sweixin = null;
							for (let i in res) {
								if (res[i].id == 'weixin') {
									sweixin = res[i];
								}
							}
							//唤醒微信小程序
							if (sweixin) {
								sweixin.launchMiniProgram({
									id: 'gh_356131c8d206', //
									type: 2, //小程序版本  0-正式版； 1-测试版； 2-体验版。
									path: 'pages/billdetails/billdetails?data='+str//小程序的页面,用传的参数在小程序接值判断跳转
								});
							}
							console.log(str)
						}
				);
				// let res = await this.$request.api.getWxPay({
				// 	id: this.$Route.query.id,
				// 	mobile: uni.getStorageSync('phone'),
				// 	open_id: uni.getStorageSync('openId'),
				// 	proId: this.homelist.proId,
				// 	pay_type: 'wx_lite', //（支付渠道）
				// 	goods_title: '小程序物业收费', //（商品标题）
				// 	goods_desc: '小程序物业收费', //（商品描述信息）
				// 	allMoney: Number(this.money).toFixed(2),
				// 	code: this.billList.order.code
				// })
				// if(res.data.status != 200){
				// 	uni.showToast({
				// 		icon:'none',
				// 		title:res.data.msg
				// 	})
				// 	return
				// }
				// let pay_info = JSON.parse(res.data.data.expend.pay_info)

				// uni.requestPayment({
				// 	provider: 'wxpay',
				// 	timeStamp: pay_info.timeStamp,
				// 	nonceStr: pay_info.nonceStr,
				// 	package: pay_info.package,
				// 	signType: pay_info.signType,
				// 	paySign: pay_info.paySign,
				// 	success: function(res) {
				// 		console.log('success:' + JSON.stringify(res));
				// 	},
				// 	fail: function(err) {
				// 		console.log('fail:' + JSON.stringify(err));
				// 	}
				// });
			}
		}
	}
</script>

<style scoped lang="scss">
	page {
		background-color: rgb(244, 244, 244);

	}

	.billdetails {
		padding: 0 30rpx;
	}

	.billdetails_top {
		height: 312rpx;
		text-align: center;
		background-color: #fff;
		margin-top: 60rpx;
		border-top-left-radius: 6px;
		border-top-right-radius: 6px;

		.name {
			padding-top: 60rpx;
			box-sizing: border-box;

		}

		.last {
			margin-top: 20rpx;
			color: rgb(128, 229, 255);
		}

		.moeny {
			font-size: 48rpx;
			color: #000;
			font-weight: bold;
			margin-top: 60rpx;
		}
	}

	.xian {
		height: 50rpx;
		background-color: #fff;
		display: flex;
		justify-content: space-between;

		.xian_center {
			height: 1px;
			border-top: 1px dashed #ccc;
			margin: 25rpx 40rpx;
			width: 600rpx;

		}

		.xian_left {
			width: 50rpx;
			height: 50rpx;
			border-radius: 50%;
			float: left;
			background-color: rgb(244, 244, 244);
			margin-left: -7vw;
		}
		.xian_right {
			width: 50rpx;
			height: 50rpx;
			border-radius: 50%;
			float: right;
			background-color: rgb(244, 244, 244);
			margin-right: -7vw;

		}
	}

	.zdbh {
		margin-bottom: 30rpx;

		.bh {
			float: left;
		}

		.num {
			float: right;
		}
	}

	.wyf {
		.wyfname {
			float: left;
		}

		.wyfmoney {
			float: right;
		}

		.view {
			margin-bottom: 30rpx;
		}
	}

	.main_jh {
		margin-bottom: 60rpx;
	}

	.main {
		background-color: #fff;
		padding: 60rpx 20rpx;
	}

	.bill-deta-btn {
		width: 100%;
		height: 40rpx;
	}
</style>
